import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'

import { MerchantListComponent } from './list/list.component'
import { MerchantNewComponent } from './new/new.component'
import { NewRouterGuardClass } from '@shared/classes/NewRouterGuardClass'
import { MerchantDetailComponent } from './detail/detail.component'
import { MerchantDetailTabStoreComponent } from './detail/tab-store/tab-store.component'
import { MerchantDetailTabSettlementComponent } from './detail/tab-settlement/tab-settlement.component'
import { MerchantDetailTabSystemComponent } from './detail/tab-system/tab-system.component'
import { MerchantDetailTabUserComponent } from './detail/tab-user/tab-user.component'
import { MerchantNewTradeComponent } from './new/trade/trade.component'
import { MerchantDetailTabTradeComponent } from './detail/tab-trade/tab-trade.component'
import { MerchantEditTradeComponent } from './add/trade/trade.component'
import { ListRouterGuardClass } from '@shared/classes/ListRouterGuardClass'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass'

const routes: Routes = [
  { path: '', redirectTo: 'list', data: { title: '商户列表' }, component: MerchantListComponent, pathMatch: 'full' },
  {
    path: 'list',
    component: MerchantListComponent,
    canActivate: [ListRouterGuardClass, ListReuseGuardClass],
    pathMatch: 'full',
    data: {
      title: '商户列表',
      titleI18n: 'MENU.BIZ.MERCHANTS',
      reuse: true,
    },
  },
  {
    path: 'new',
    component: MerchantNewComponent,
    canDeactivate: [NewRouterGuardClass],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.CREATE',
      titleI18n: 'BIZ.MERCHANT.TITLE.CREATE',
    },
  },
  {
    path: ':id',
    component: MerchantDetailComponent,
    children: [
      { path: '', redirectTo: 'stores', pathMatch: 'full' },
      {
        path: 'stores',
        component: MerchantDetailTabStoreComponent,
        data: {
          titleI18n: 'BIZ.MERCHANT.TITLE.DETAIL',
        },
      },
      {
        path: 'settlements',
        component: MerchantDetailTabSettlementComponent,
        data: {
          titleI18n: 'BIZ.MERCHANT.TITLE.DETAIL',
        },
      },
      {
        path: 'systems',
        component: MerchantDetailTabSystemComponent,
        data: {
          titleI18n: 'BIZ.MERCHANT.TITLE.DETAIL',
        },
      },
      {
        path: 'users',
        component: MerchantDetailTabUserComponent,
        data: {
          titleI18n: 'BIZ.MERCHANT.TITLE.DETAIL',
        },
      },
      {
        path: 'trades',
        component: MerchantDetailTabTradeComponent,
        data: {
          titleI18n: 'BIZ.MERCHANT.TITLE.DETAIL',
        },
      },
    ],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.DETAIL',
      title: '商户详情',
      titleI18n: 'BIZ.MERCHANT.TITLE.DETAIL',
    },
  },
  {
    path: ':id/trades/edit',
    component: MerchantEditTradeComponent,
    data: {
      breadcrumb: 'BIZ.MERCHANT.TITLE.AUTH_CODE_RESET',
      titleI18n: 'BIZ.MERCHANT.TITLE.AUTH_CODE_RESET',
    },
  },
]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class MerchantRoutingModule {}
